<%@ page pageEncoding="UTF-8" %>
<%@ include file="common/global.jsp" %>
<%@ taglib prefix="security" uri="/security" %>
<!doctype html>
<html>
<head>
    <%@ include file="common/meta.jsp" %>
    <title><f:message key="common.title"/> - <f:message key="login"/></title>
    <%@ include file="common/css.jsp" %>
</head>

<body>

<div id="content">

    <div class="container">

        <div class="row">

        <form id="message_edit_form" class="form-horizontal">

            <fieldset>

                <div class="control-group">
                    <label class="control-label" for="id">处理器id:</label>
                    <div class="controls">
                        <input type="text"  id="id" name="id" value="1" class="ext-required">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="message">自定义消息:</label>
                    <div class="controls">
                        <select id="msgType" name="MsgType" onchange="msgFn(this)">
                            <option value="">选择消息类型</option>
                            <option value="text">文本消息</option>
                            <option value="image">图片消息</option>
                            <option value="voice">语音消息</option>
                            <option value="video">视频消息</option>
                            <option value="location">地理位置消息</option>
                            <option value="link">链接消息</option>
                        </select>
                    </div>

                </div>

                <div class="control-group">
                    <label class="control-label" for="message">发送内容:</label>
                <div class="controls">
                        <textarea class="span6" name="message" id="message" rows="8"></textarea>
                    </div>
                </div>
                <label class="control-label" for="message">接收内容:</label>
                <div class="controls">
                    <textarea class="span6" name="message2" id="message2" rows="8"></textarea>
                </div>


                <div class="form-actions">

                    <button type="submit" class="btn btn-primary">
                        提交
                    </button>

                </div>

            </fieldset>
        </form>
       </div>
    </div> <!-- /.container -->

</div> <!-- /#content -->

<%@ include file="common/js.jsp"%>

<script type="text/javascript">
    $(function() {
        $('#message_edit_form').ajaxForm({
            type: 'post',
            url: BASE + '/test',
            dataType: 'json',
            beforeSubmit: function() {
                return Smart.Validator.checkRequired('message_edit_form');
            },
            success: function(result) {
                if (result.success) {
                    $('#message2').val(result.data);
                }
            }
        });

    });

    msgFn=function(obj){
        $.ajax({
            type: 'get',
            url: BASE + '/message/' + obj.value,
            dataType: 'json',
            beforeSubmit: function() {
                return Smart.Validator.checkRequired('message_edit_form');
            },
            success: function(result) {
                if (result.success) {
                    $('#message').val(result.data);
                }
            }
        });

    };



</script>

</body>
</html>